#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
	/**/
	int l_iFifo;
	int l_iData = 0;
	l_iFifo = mkfifo("/tmp/fifo_ac",0666);

	//Check fifo has been created successfully.
	if(l_iFifo < 0)
	{
		printf("Unable to create FIFO, exiting.. with code %d\n",l_iFifo);
//		return -1;
	}

	//Wait for 3 Seconds and open fifo
	printf("Start fifoReader in 5 seconds..\n");
	sleep(5);
	//Open fifo
	
	l_iFifo = open("/tmp/fifo_ac",O_RDWR);
	if(l_iFifo < 0)
	{
		printf("Unable to open FIFO, exiting..\n");
		return -1;
	}

	//Check opening of fifo is successful
	for(l_iData = 0 ; l_iData < 10 ; l_iData++)
	{
		printf("Writing %d to fifo..\n",l_iData);
		write(l_iFifo,&l_iData,sizeof(int));
		sleep(1);
	}
	return 0;
} 
